<?php
/**
*
*/
class NewPlaceS2_model extends Model
{

	function __construct()
	{
		parent:: __construct();
	}
	public function newPlaceS2()
	{
		$error			= array();
		$CategoriesName = $this->f->validate_input_text('/^[\w\'.-]{2,20}$/i',$_POST['CategoriesName']);
		$Position 		= $this->f->validate_input_text('/^[\w\'.-]{2,20}$/i',$_POST['Position']);
		$WorkingDay 	= $this->f->validate_input_text('/^[\w\'.-]{2,20}$/i',$_POST['WorkingDay']);
		$WorkingTime 	= $this->f->validate_input_text('/^[\w\'.-]{2,20}$/i',$_POST['WorkingTime']);
		$ServiceName 	= $this->f->validate_input_text('/^[\w\'.-]{2,20}$/i',$_POST['ServiceName']);

		$Status			= $this->f->validate_input_text('/^[\w\'.-]{2,20}$/i',$_POST['Status']);
		$Menu 			= $this->f->validate_url($_POST['Menu']);
		$count 		= 0;

		if($CategoriesName 	== false) $error[] = 'CategoriesName';
		if($Position 		== false) $error[] = 'Position';
		if($WorkingDay 		== false) $error[] = 'WorkingDay';
		if($WorkingTime 	== false) $error[] = 'WorkingTime';

		if($ServiceName 	== false) $error[] = 'ServiceName';

		if($Status 			== false) $error[] = 'Status';
		if($Menu 			== false) $error[] = 'Menu';
		

		if(empty($error))
		{
			$q = $this->db->prepare(
							"INSERT INTO places (
								CategoriesName,
								Position,
								WorkingDay,
								WorkingTime,
								ServiceName,
								Status,
								Menu,)
							VALUES (
								:CategoriesName,
								:Position,
								:WorkingDay,
								:WorkingTime,
								:ServiceName,
								:Status,
								:Menu)");
			$value = $q->execute(array(
				':CategoriesName' 	=> 	$CategoriesName,
				':Position'			=>	$Position,
				':WorkingDay' 		=> 	$WorkingDay,
				':WorkingTime'		=>	$WorkingTime,

				':ServiceName' 		=> 	$ServiceName,

				':Status'			=>	$Status,
				':Menu'				=>	$Menu
			));

			$error[] =  $value;
		}
		echo json_encode($error);
	}
}
?>